package com.example.demo1.service;


import com.example.demo1.Entity.Role;
import com.example.demo1.Entity.Status;
import com.example.demo1.Entity.User_table;
import com.example.demo1.repository.User_table_repository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.stereotype.Service;

@Service
public class User_table_serviceImpl implements User_table_service{
    @Autowired
    private User_table_repository user_table_repository;

    @Transactional
    @Override
    public User_table UserTableSet(String username,
                                   String password,
                                   Role role,
                                   Status status
                                  ) {

        // 创建实体对象
       User_table user_table = new User_table();
        user_table.setUsername(username);
        user_table.setUserpassword(password);
        user_table.setRole(role);
        user_table.setStatus(status);

        return user_table;
    }
    @Transactional
    @Override
    public void save_data(User_table A) {
        user_table_repository.save(A);
        System.out.println("插入成功！ID: " + A.getId());
    }
}
